#include <led.h>

u8 led_y_stats = 1;
u8 led_b_stats = 1;
u8 led_g_stats = 1;

/**
 * LED 初始化：
 * P35: 黄色LED
 * P36: 蓝色LED
 * P37: 绿色LED
 */
void LED_Init(void) {
    GPIO_InitTypeDef initTypeDef;
    initTypeDef.Mode = GPIO_OUT_PP;
    initTypeDef.Pin =  GPIO_Pin_5 | GPIO_Pin_6 | GPIO_Pin_7;
    GPIO_Inilize(GPIO_P3, &initTypeDef); // 设置P0.4、P0.5为漏极开路(实验箱加了上拉电阻到3.3V)
}

void Sample_Lamp(void) {
    led_reversal('y');
}

void led_reversal(u8 led){
    switch (led)
    {
    case 'y':
    case 'Y':
        LED_H = led_y_stats;
        led_y_stats = !led_y_stats;
        break;
    case 'b':
    case 'B':
        LED_B = led_b_stats;
        led_b_stats = !led_b_stats;
        break;
    case 'g':
    case 'G':
        LED_G = led_g_stats;
        led_g_stats = !led_g_stats;
        break;
    
    default:
        break;
    }
}